<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>INSPINIA | Basic Form</title>
</head>

<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i>   <a>管理员</a>
                    </li>
                    <li class="active">
                        <strong>详情</strong>
                    </li>
                </ol>
                <span class="navbar-right  m-r m-t-8"><a href="javascript:history.go(-1);" class="btn-primary btn-add "> <i class='fa fa-mail-reply'></i> 返回</a></span>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <form method="get" data-ajax="${ctx}/admin/sys/admin/list"   form-before="before()"   action="${ctx}/admin/sys/admin/${method}"  class="form-horizontal" id="user_form">
                                <input  type="hidden" name="adminId" id="adminId"  value="${admin.adminId}"/>
                                <div class="form-group"><label class="col-sm-2 control-label">账号</label>
                                    <div class="col-sm-6 m-t-sm7">${admin.username}</div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-6 m-t-sm7 ">${admin.name}</div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">手机号</label>
                                    <div class="col-sm-6 m-t-sm7 ">${admin.tel}</div>
                                </div>
                                
                                <div class="form-group"><label class="col-sm-2 control-label">角色</label>
                                    <div class="col-sm-6 m-t-sm7  ">
                                            <c:forEach var="role" items="${roles}" >
                                               ${role.roleName}
                                            </c:forEach>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">职位</label>
                                    <div class="col-sm-6 m-t-sm7 ">${admin.position}</div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">添加时间</label>
                                    <div class="col-sm-6 m-t-sm7 "><fmt:formatDate value="${admin.createTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate> </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">状态</label>
                                    <div class="col-sm-6 m-t-sm7 ">
                                        <c:choose>
                                            <c:when test="${admin.adminState==0}">
                                                使用中
                                            </c:when>
                                            <c:when test="${admin.adminState==1}">
                                                禁用
                                            </c:when>
                                            <c:otherwise>
                                                --
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </div>

                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>

    $(document).ready(function() {
         var select2_role =  $(".select2_role").select2();

        <c:if test="${method=='update'}">
              var rids="${rids}";
              select2_role.val(eval("(["+rids+"])")).trigger('change');
        </c:if>
    });

    var before =function(){
        var username=$("#username").val();
        var adminId=$("#adminId").val();

        var relt;
        $.ajax({
            url: "${ctx}/admin/sys/admin/existed",
            method: "POST",
            async: false,
            data: {"username" : username,"adminId":adminId},
            dataType: "json",
            success : function(response) {
                if (response.success) {
                    relt= true;
                } else {
                    parent.layer.alert(username+'已存在');
                    relt = false;
                }
            }
        });
        return relt;
    }

    var resetPsd =function(){
        parent.layer.confirm('是否确认重置密码？', function() {
            $.ajax({
                url: "${ctx}/admin/sys/admin/resetPass",
                method: "POST",
                data: {"adminId" : "${admin.adminId}"},
                dataType: "json",
                success : function(response) {
                    if (response.success) {
                        parent.layer.alert('重置成功');
                    } else {
                        parent.layer.alert('重置失败');
                    }
                }
            });
        })
    }
</script>
</body>

</html>
